/*Source

Problem Id:2691  User Id:Latex 
Memory:1168K  Time:0MS
Language:G++  Result:Accepted

Source 
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>

#define maxn 10010

using namespace std;


struct prop{
	int ind;
	int met;
	double price;
	char name[90];
};

int n,p;
prop item[maxn];
char str[100];

int cmp(const void * a1, const void * a2)
{
	prop *ar1=(prop *) a1;
	prop *ar2=(prop *) a2;
	if (ar1->met < ar2->met)
	{
		return 1;
	}else if (ar1->met > ar2->met)
	{
		return -1;
	}else
	{
		if (ar1->price < ar2->price)
		{
			return -1;
		}else if (ar1->price > ar2->price)
		{
			return 1;
		}else
		{
			return ar1->ind - ar2->ind;
		}
	}
}


int main()
{
	int i,j,k=0;
	
	while (scanf("%d%d", &n, &p), n>0)
	{
		memset(item, 0, sizeof (item));
		if (k)
			printf("\n");
		gets(str);
		for (i=0;i<n;i++)
			gets(str);
		for (i=0;i<p;i++)
		{
			gets(item[i].name);
			item[i].ind=i;
			scanf("%lf%d", &item[i].price, &item[i].met);
			gets(str);
			for (j=0;j<item[i].met;j++)
				gets(str);
		}
		qsort(item, p, sizeof(prop), cmp);
		
		printf("RFP #%d\n", ++k);
		printf("%s\n", item[0].name);
	}
	return 0;
}


